package logic

import (
	"bw-renting/model/mysql"
	"bw-renting/user-rpc/internal/svc"
	"bw-renting/user-rpc/user"
	"context"
	"encoding/json"
	"github.com/zeromicro/go-zero/core/logx"
)

type UserInfoRequestLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserInfoRequestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoRequestLogic {
	return &UserInfoRequestLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// Todo:获取用户信息
func (l *UserInfoRequestLogic) UserInfoRequest(in *user.GetUserInfoReq) (*user.GetUserInfoRes, error) {
	// todo: add your logic here and delete this line
	u := mysql.GetUser(in.UserID)
	u1, _ := json.Marshal(u)
	return &user.GetUserInfoRes{
		Code:    200,
		Message: string(u1),
	}, nil
}
